SIMBAT_BASE=/home/yaojie/simbat
ENTERPRISE=-DSIMBAT_ENTERPRISE
INC_PATH=$(SIMBAT_BASE)/include
LIB_PATH=$(SIMBAT_BASE)/lib
BIN_PATH=$(SIMBAT_BASE)/bin

CFLAGS=-DBK_LINUX -I$(INC_PATH) -L$(LIB_PATH) -m64 -fPIC -rdynamic $(ENTERPRISE)
CPPFLAGS=-DBK_LINUX -I$(INC_PATH) -L$(LIB_PATH) -m64 -fPIC -rdynamic -O2 $(ENTERPRISE)

SHARE_FLAG=-shared
CXX=c++
DLL_SUFFIX=so

all :
	sh ./makeall

install :
	$(SIMBAT_BASE)/bin/simbat_mkinstall

simbat_install :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp
	mv $@ $(BIN_PATH)

libsimbat :
	$(CXX) $(CPPFLAGS) $(SHARE_FLAG) -o $@.$(DLL_SUFFIX) bkbase.c bkipc.c bstcp.c h_base.cpp h_xml.cpp simbat.cpp h_lz77.cpp h_conv.cpp h_thread.cpp -lpthread
	mv $@.$(DLL_SUFFIX) $(LIB_PATH)
simbat_mkinstall :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp
	mv $@ $(BIN_PATH)
simbat_ctl :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_sch :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat -ldl
	mv $@ $(BIN_PATH)
simbat_evnt :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_exec :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_pass :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_setvar :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_getvar :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_check :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_db :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat -ldl
	mv $@ $(BIN_PATH)
simbat_datafile :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat -ldl
	mv $@ $(BIN_PATH)
simbat_diff :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_tst :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_mksts :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_query :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_backup_file :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_http_post :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_clean :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
simbat_batch :
	$(CXX) $(CPPFLAGS) -o $@ $@.cpp -lsimbat
	mv $@ $(BIN_PATH)
